using System;
using System.Collections;
using System.Diagnostics.Contracts;
using System.Reflection;

namespace Charisma.Metadata
{
    internal sealed class MetaFieldDescription
    {
        public MetaFieldDescription(string name, string alias, MemberInfo field)
        {
            Contract.Requires(!String.IsNullOrEmpty(name));
            Contract.Requires(field != null);
            Contract.Requires(field is PropertyInfo || field is FieldInfo);
            Contract.Requires(field is FieldInfo || ((PropertyInfo) field).CanRead);

            Name = name;
            Alias = alias;
            Field = field;
        }

        public string Name { get; private set; }
        public string Alias { get; private set; }
        public MemberInfo Field { get; private set; }
        public Func<object, IList, IEnumerable> CollectionInitializer { get; set; }
    }
}